<!-- 菜谱展示页 -->
<?php echo $this->Html->css("details");
      $difficult = array(
        0=>"新手",
        1=>"初级",
        2=>"初中",
        3=>"中级",
        4=>"高级",
        5=>"厨神"
      );
 ?> 
<div id="displayRecipe">
<?php
 echo $this->Session->flash('auth'); 
    echo $this->Session->flash();

    ?>
  <table border="0">
    <tr>
      <td id="recipeImg"><?php echo $this->Html->image($recipe['Recipe']['img'], array('width' => '100%')); ?></td>
      <td width="10"></td>
      <td id="breifDescription">
        <div id="evaluateBox">
          <div id="starChoose">评级</div>
          <ul id="starList">
            <li score="1">一星</li>
            <li score="2">二星</li>
            <li score="3">三星</li>
            <li score="4">四星</li>
            <li score="5">五星</li>
          </ul>
        </div>
        <div class="recipeProperty"id="recipeTitle"><?php echo $recipe['Recipe']['name']; ?></div>
        <div class="clearFix" />
        <div class="recipeProperty"id="recipeTags">
        <?php 
              $tag_array = explode(" ",$recipe['Recipe']['tags']);
            $number = count($tag_array);
            for($i = 0; $i < $number; $i++){
              echo "<a>".$tag_array[$i]."</a>";
            }
        ?></div>
        <div class="clearFix" />
        
        <div class="clearFix" />
        <div class="recipeProperty"id="recipeTaste"><div>口味</div><span><?php echo $recipe['Recipe']['taste']; ?></span></div>
        <div class="recipeProperty"id="recipeDifficulty"><div>难度</div><span><?php echo $difficult[$recipe['Recipe']['difficulty']]; ?></span></div>
        <div class="recipeProperty"id="recipePrepareTime"><div>准备时间</div><span><?php echo $recipe['Recipe']['prepareTime']; ?></span></div>
        <div class="recipeProperty"id="recipeCookTime"><div>烹饪时间</div><span><?php echo $recipe['Recipe']['cookTime']; ?></span></div>
        <div class="recipeProperty"id="recipeMethod"><div>工艺</div><span><?php echo $recipe['Recipe']['method']; ?></span></div>
        <div class="clearFix" />
        <div class="recipeProperty"id="recipeDescription"><?php echo $recipe['Recipe']['description']; ?></div>
        <table id="ingredient" border="0">
          <tr>
            <td class="ingredientType">
              <div>主料</div>
            </td>
            <td>
              <ul id="ingredientType0">
                <?php
                $ingredient_array = explode(" ",$recipe['Recipe']['ingredient0']);
          $number = count($ingredient_array);
          for($i = 0; $i < $number; $i++){
            echo '<li class="ingredientItem"><div class="ingredientItemTitle">'.$ingredient_array[$i].'</div><div class="ingredientItemAmount">30克</div></li>';
          }
                ?>
              </ul>
            </td>
          </tr>
          <tr>
            <td class="ingredientType">
              <div>辅料</div>
            </td>
            <td>
              <ul id="ingredientType1">
                <?php
                $ingredient_array = explode(" ",$recipe['Recipe']['ingredient1']);
          $number = count($ingredient_array);
          for($i = 0; $i < $number; $i++){
            echo '<li class="ingredientItem"><div class="ingredientItemTitle">'.$ingredient_array[$i].'</div><div class="ingredientItemAmount">30克</div></li>';
          }
                ?>
              </ul>
            </td>
          </tr>
          <tr>
            <td class="ingredientType">
              <div>调料</div>
            </td>
            <td>
              <ul id="ingredientType2">
                <?php
                $ingredient_array = explode(" ",$recipe['Recipe']['ingredient2']);
          $number = count($ingredient_array);
          for($i = 0; $i < $number; $i++){
            echo '<li class="ingredientItem"><div class="ingredientItemTitle">'.$ingredient_array[$i].'</div><div class="ingredientItemAmount">30克</div></li>';
          }
                ?>
              </ul>
            </td>
          </tr>
        </table>
        <div id="ownerBox">
          <img id="ownerLogo" src="<?php echo $recipe['User']['url']; ?>" />
          发布者：<?php echo $this->Html->link($recipe['User']['username'], array('controller'=>'users','action' => 'userCenter', $recipe['User']['id'])); ?></a><div class="recipeProperty"id="recipeCreatedTime"><span><?php echo $recipe['Recipe']['createdTime']; ?></span></div>
        </div>
      </td>
    </tr>
  </table> 
</div>

<div id="displayRecipeStep">
  <div id="stepTitle">步骤</div>
  <hr>
  <div>
    <?php echo $recipe['Recipe']['content']; ?>
  </div>
</div>

<div id="displayRecipeComment">
  <div id="recipeComment">评论</div>
  <hr />
  <div style="display:<?php echo isset($_SESSION['username'])?'block;':'none;'; ?>">
  <?php echo $this->Form->create('Recipe', array('url' => array('controller' => 'Recipes', 'action' => 'comment'))); ?>
    <textarea name="data[Comment][discription]" id="commentArea"></textarea>
    <br />
    <input type="hidden" name="data[Comment][recipeId]" value="<?php echo $recipe['Recipe']['id']; ?>"/>
    <input type="submit" id="postComment" value="提交评论"/>
  </form>
  <hr />
  </div>
  <div>
    <ul id="commentList">
    <?php
      $usergroup = 0;
      if (isset($_SESSION['usergroup']))
        $usergroup = $_SESSION['usergroup'];
      if (count($comments) == 0) echo '<div class="noContent">还没有评论呐<br />╮(╯▽╰)╭</div>';
      else foreach ($comments as $comment):
    ?>
      <li>
        <a class="userlink"><img class="commentLogo" src="<?php echo $comment['User']['url']; ?>"/><br/><?php echo $comment['User']['username'];?></a>
        <div class="commentContent"><?php echo $comment['Comment']['discription'];?><div class="commentCreatedTime"><?php echo $comment['Comment']['createdTime']; ?></div><?php if ($usergroup == 1) echo "<div class='operation'>{$this->Html->link('删除',array('controller'=>'Recipes','action'=>'delComment',$comment['Comment']['id'],$recipe['Recipe']['id']),array(),
                '确定删除么？')}</div>";?></div>
        <div class="clearFix"></div>
      </li>
    <?php endforeach; ?>
      <div class="clearFix"></div>
    </ul>
  </div>
</div>
<script>
  $(document).ready(function(){

    $("#starList li").click(function(){
      $.post('<?php echo $this->Html->url(array("controller"=>"Recipes","action"=>"evalue",$recipe["Recipe"]["id"]))?>',
        {"data[score]":$(this).attr('score')},
        function (data){
          data = JSON.parse(data);
          $("#evaluateBox").empty().append("评分成功，当前分数："+data[0]['recipe']['currentScore']*2);
        });
    })
  })
</script>